package fun.symtable.tablemodel;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import fun.symtable.SymbolTableIterator;

public abstract class SymbolTableModel<T> extends AbstractTableModel {
    protected ArrayList<T> data = new ArrayList<T>();
    protected ArrayList<String> scope = new ArrayList<String>();

    public void setData(SymbolTableIterator<T> iter) {
	data.clear();
	scope.clear();
	while (iter.hasNext()) {
	    scope.add(iter.getScope());
	    data.add(iter.next());
	}
	this.fireTableDataChanged();
    }

    public T getValue(int row) {
	return data.get(row);
    }

    public int getRowCount() {
	return data.size();
    }
}
